{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "# 示例说明\n",
    "\n",
    "## 项目创建\n",
    "\n",
    "使用 poetry 工具创建项目\n",
    "\n",
    "```sh\n",
    "poetry new poetry_created_project\n",
    "```\n",
    "\n",
    "## 配置环境\n",
    "\n",
    "执行环境初始化操作。\n",
    "\n",
    "```sh\n",
    "cd poetry_created_project\n",
    "poetry install\n",
    "```\n",
    "\n",
    "添加依赖\n",
    "\n",
    "```sh\n",
    "poetry add matplotlib\n",
    "```\n",
    "\n",
    "显示已经安装的依赖\n",
    "\n",
    "```sh\n",
    "poetry show\n",
    "```\n",
    "\n",
    "## 运行程序\n",
    "\n",
    "### 运行方式 1\n",
    "\n",
    "通过标准命令行运行\n",
    "\n",
    "```sh\n",
    "python -m poetry_created_project.main\n",
    "```\n",
    "\n",
    "### 运行方式 2\n",
    "\n",
    "通过 `vscode` 插件运行。\n",
    "\n",
    "点击文件页面上面的运行按钮无法直接运行。他会提示\n",
    "\n",
    "```sh\n",
    "[Running] python -u \"/Users/asterisk/Codes/zuoyu/py_study_demo/project1/src/main.py\"\n",
    "Traceback (most recent call last):\n",
    "  File \"/Users/asterisk/Codes/zuoyu/py_study_demo/project1/src/main.py\", line 1, in <module>\n",
    "    from .modules.method1 import multiply\n",
    "ImportError: attempted relative import with no known parent package\n",
    "```\n",
    "\n",
    "### 运行方式 3\n",
    "\n",
    "通过创建 launch.json 配置文件来运行\n",
    "\n",
    "```json\n",
    "{\n",
    "  \"version\": \"0.2.0\",\n",
    "  \"configurations\": [\n",
    "    {\n",
    "      \"name\": \"Python Debugger: Module\",\n",
    "      \"type\": \"debugpy\",\n",
    "      \"request\": \"launch\",\n",
    "      \"cwd\": \"${workspaceFolder}/poetry_created_project\",\n",
    "      \"module\": \"poetry_created_project.main\"\n",
    "    }\n",
    "  ]\n",
    "}\n",
    "```\n",
    "\n",
    "## 测试\n",
    "\n",
    "暂无。\n",
    "\n",
    "## 其他\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "vscode": {
     "languageId": "shellscript"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "50291.10s - pydevd: Sending message related to process being replaced timed-out after 5 seconds\n",
      "/Users/asterisk/Codes/zuoyu/py_study_demo/project3\n"
     ]
    }
   ],
   "source": [
    "# 在 Jupyter Notebook 中执行 shell 命令\n",
    "!pwd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "vscode": {
     "languageId": "shellscript"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "50383.08s - pydevd: Sending message related to process being replaced timed-out after 5 seconds\n",
      "README.ipynb           README.md              \u001b[1m\u001b[34mpoetry_created_project\u001b[m\u001b[m\n"
     ]
    }
   ],
   "source": [
    "!sh -c \"ls\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "vscode": {
     "languageId": "shellscript"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "50468.06s - pydevd: Sending message related to process being replaced timed-out after 5 seconds\n",
      "3\n",
      "Figure(640x480)\n"
     ]
    }
   ],
   "source": [
    "!sh -c \"cd poetry_created_project && python -m poetry_created_project.main\""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
